﻿// =================================================================== 
// 数据实体层(GDIT.Model)实体映射
//====================================================================
// 文件：Mtb_CollegeInformationArticle.cs
// 项目名称：学院网站
// 创建时间：2012-08-08
// 负责人：ChenZhiGang
// 引用DevExpress.Xpo程序集
// 程序集介绍：校园资讯实体类
// ===================================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DevExpress.Xpo;

namespace GDIT.Model
{
    public class Mtb_CollegeInformationArticle : PersistentClass
    {
             public Mtb_CollegeInformationArticle()
            : base()
        {
            this.Modified = false;
        }

             public Mtb_CollegeInformationArticle(Session theSession)
            : base(theSession)
        {
            this.Modified = false;
        }

        private string _title = string.Empty;
        /// <summary>
        /// 校园资讯标题
        /// </summary>
        [DbType("varchar(100)")]
        public string Title
        {
            get { return _title; }
            set
            {
                if (_title != value)
                {
                    _title = value;
                    if (!IsLoading) { this.Modified = true; }
                }
            }
        }

        private string _contents = string.Empty;
        /// <summary>
        /// 校园资讯内容
        /// </summary>
        [DbType("nvarchar(MAX)")]
        public string Contents
        {
            get { return _contents; }
            set
            {
                if (_contents != value)
                {
                    _contents = value;
                    if (!IsLoading) { this.Modified = true; }
                }
            }
        }

        private DateTime _publishDate = DateTime.Now;
        /// <summary>
        /// 校园资讯发布时间
        /// </summary>
        [DbType("datetime")]
        public DateTime PublishDate
        {
            get { return _publishDate; }
            set
            {
                if (_publishDate != value)
                {
                    _publishDate = value;
                    if (!IsLoading) { this.Modified = true; }
                }
            }
        }

        /// <summary>
        /// 校园资讯发布人
        /// </summary>
        [Association("UserCollegeInformationArticles")]
        public Mtb_Users Publisher;

        /// <summary>
        /// 文章所包含的关键字
        /// </summary>
        [Association("CollegeInformationArticleKeyWords", typeof(Mtb_CollegeKeyWord))]
        public XPCollection KeyWords
        {
            get
            {
                return GetCollection("KeyWords");
            }
        }


        private string _top = "否";
        /// <summary>
        /// 校园资讯是否置顶
        /// </summary>
        [DbType("varchar(2)")]
        public string Top
        {
            get { return _top; }
            set
            {
                if (_top != value)
                {
                    _top = value;
                    if (!IsLoading) { this.Modified = true; }
                }
            }
        }

        private int _counter = 0;
        /// <summary>
        /// 校园资讯被浏览数
        /// </summary>
        [DbType("int")]
        public int Counter
        {
            get { return _counter; }
            set
            {
                if (_counter != value)
                {
                    _counter = value;
                    if (!IsLoading) { this.Modified = true; }
                }
            }
        }

        private string _visible = "否";
        /// <summary>
        /// 公告是否内部显示
        /// </summary>
        [DbType("varchar(2)")]
        public string IsVisible
        {
            get { return _visible; }
            set
            {
                if (_visible != value)
                {
                    _visible = value;
                    if (!IsLoading) { this.Modified = true; }
                }
            }
        }

        private string _internal = "否";
        /// <summary>
        /// 校园资讯是否内部显示
        /// </summary>
        [DbType("varchar(2)")]
        public string Internal
        {
            get { return _internal; }
            set
            {
                if (_internal != value)
                {
                    _internal = value;
                    if (!IsLoading) { this.Modified = true; }
                }
            }
        }

        private string _important = "否";
        /// <summary>
        /// 校园资讯是否重点
        /// </summary>
        [DbType("varchar(2)")]
        public string Important
        {
            get { return _important; }
            set
            {
                if (_important != value)
                {
                    _important = value;
                    if (!IsLoading) { this.Modified = true; }
                }
            }
        }

        /// <summary>
        /// 防止编辑后马上保存
        /// </summary>
        protected override void EndEdit()
        {
            return;
        }

        /// <summary>
        /// 检验数据
        /// </summary>
        /// <returns></returns>
        public override string GetDataError()
        {
            if (this._contents.Trim().Length == 0) { return string.Format("校园资讯内容不能为空"); }
            if (this._title.Trim().Length == 0) { return string.Format("校园资讯标题不能为空"); }
            return "";
        }
    }
}
